#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
ll n,m;
ll b[300010],w[300010];
ll pre1[300010],pre2[300010],pre3[300010],pre4[300010];

int main()
{
    IOS;
    cin>>n>>m;
    for(ll i=1;i<=n;i++){
        cin>>b[i];
    }    
    for(ll i=1;i<=n;i++){
        cin>>w[i];
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(b[i]>w[i]){
            pre1[i]=pre1[i-1]+b[i];
            pre2[i]=pre2[i-1];
            ans+=b[i];
        }
        else{
            pre1[i]=pre1[i-1];
            pre2[i]=pre2[i-1]+w[i];
            ans+=w[i];
        }
    }
    for(ll i=1;i<=n;i++){
        if(b[i]<=w[i]){
            pre3[i]=pre3[i-1]+b[i];
            pre4[i]=pre4[i-1];
            // ans+=b[i];
        }
        else{
            pre3[i]=pre3[i-1];
            pre4[i]=pre4[i-1]+w[i];
            // ans+=w[i];
        }
    }
    ll l,r,t,c;
    while(m--){
        cin>>t>>l>>r>>c;
        if(t==1){
            ll sum1=pre2[r]-pre2[l-1];
            ll sum2=pre3[r]-pre3[l-1]+c;
            if(sum1<sum2){
                ans+=(sum2-sum1);
            }
        }
        else {
            ll sum1=pre1[r]-pre1[l-1];
            ll sum2=pre4[r]-pre4[l-1]+c;
            if(sum1<sum2){
                ans+=(sum2-sum1);
            }
        }
    }
    cout<<ans<<endl;
    getchar();
    getchar();
    return 0;
}
